module.exports = function(grunt) {
    grunt.initConfig({
        concat: {
            dist: {
                options: {
                    banner: '\/*<%= grunt.template.today("ddmmyyhhMMss") %>*\/\n\'use strict\'; \n/**\n* @namespace\n*/\n',
                    stripBanners: true
                },
                src: [
                    'dev/core.js',
                    'dev/const.js',
                    'dev/util.js',
                    'dev/xml.js',
                    'dev/cosa_lib/*.js',
                    'dev/request/*.js',
                    'dev/response/*.js',
                    'dev/metadata/*.js'
                ],
                dest: 'build/cosa.js'
            },
            distForTest: {
                src: ['dev/cosa_lib.js', 'dev/core.js', 'dev/const.js', 'dev/request.js', 'dev/response.js', 'dev/util.js', 'dev/xml.js'],
                dest: 'crm_test/cosa.js'
            },
            docCnctRequest: {
                src: [ 'apiDoc/requestHeader.md', 'apiDoc/request/*.*'],
                dest: 'apiDoc/output/request.md'
            },
            docCnctConst: {
                src: [ 'apiDoc/constHeader.md', 'apiDoc/const/*.*'],
                dest: 'apiDoc/output/const.md'
            },
            docCnctCosa: {
                src: [ 'apiDoc/cosaHeader.md', 'apiDoc/cosa/*.*'],
                dest: 'apiDoc/output/cosa.md'
            },
            docCnctResponse: {
                src: ['apiDoc/responseHeader.md', 'apiDoc/response/*.*'],
                dest: 'apiDoc/output/response.md'
            }
        },
        jshint: {
            files: ['dev/request.js']
        },
        uglify: {
            cosa_target: {
                files: {
                    'build/cosa.min.js': ['build/cosa.js']
                }
            }
        },
        jsdoc: {
            dist: {
                src: ['build/cosa.js'],
                options: {
                    destination: 'doc',
                    template: "node_modules/ink-docstrap/template",
                    configure: "node_modules/ink-docstrap/template/jsdoc.conf.json"
                }
            }
        },
        clean: {
            doclean: ['doc']
        },
        jsdoc2md: {
            doc: {
                src: 'build/cosa.js',
                dest: 'doc.md'
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-jsdoc');
    grunt.loadNpmTasks('grunt-jsdoc-to-markdown');
    grunt.loadNpmTasks('grunt-contrib-clean');

    grunt.registerTask('dev', ['concat:dist']);
    grunt.registerTask('minifyMe', ['uglify']);
    grunt.registerTask('makeSomeDoc', ['clean:doclean','jsdoc']);
    grunt.registerTask('mddoc', ['concat', 'jsdoc2md']);
    grunt.registerTask('docConcat', ['concat:docCnctRequest', 'concat:docCnctConst', 'concat:docCnctCosa']);
};
